#define _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>

int main()
{
	int a = 0, b = 0, c = 0;
	scanf("%d %d", &a, &b);
	if (a < b)
	{
		c = a;
		a = b;
		b = c;
	}
	while (b != 0)
	{
		c = b;
		b = a % b;
		a = c;
	}
	printf("%d", a);
	return 0;
}